package com.li.springbootproject.spring.propertiesinto;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2021年11月20日 16:52:00
 */
@Configuration
@PropertySource(value="classpath:/test/people.properties",encoding = "UTF-8")
public class PeopleBeanOne {

    private static final Logger logger = LoggerFactory.getLogger(PeopleBeanOne.class);

    @Value("${people.id}")
    private String id;

    @Value("${people.name}")
    private String userName;

    @Value("${people.address}")
    private String address;


    @Bean
    public PeopleBeanOne initPeopleBean() {
        PeopleBeanOne people = new PeopleBeanOne();
        people.setId(id);
        people.setUserName(userName);
        people.setAddress(address);
        logger.info("peoplebean info :{}", people);
        return people;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public String toString() {
        return "PeopleBean{" +
                "id='" + id + '\'' +
                ", userName='" + userName + '\'' +
                ", address='" + address + '\'' +
                '}';
    }
}
